package com.itboye.mengwu.collection;

import java.util.ArrayList;
import java.util.Observable;
import java.util.Observer;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentStatePagerAdapter;
import android.support.v4.view.ViewPager;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageView;
import android.widget.ListView;

import com.itboye.core.alert.ByAlert;
import com.itboye.core.object.BaseFragment;
import com.itboye.core.object.ResultEntity;
import com.itboye.core.object.SpPublicParams;
import com.itboye.core.utils.SPUtils;
import com.itboye.mengwu.R;
import com.itboye.mengwu.app.adapter.GoodsCollectionAdapter;
import com.itboye.mengwu.app.ui.main.GoodsListActivity;
import com.itboye.mengwu.app.ui.roof.HomePageItemFragmentTypeTwo;
import com.itboye.mengwu.app.ui.roof.TodaySpecialOfferItemFragment;
import com.itboye.mengwu.data.model.GoodsListModel;
import com.itboye.mengwu.data.model.IndexModel;
import com.itboye.mengwu.data.presenter.AddGoodsPresenter;
import com.itboye.mengwu.data.presenter.LunBoPresenter;
import com.itboye.mengwu.data.presenter.TieZiPresenter;
import com.itboye.mengwu.widget.PagerSlidingTabStrip;

/***
 * 内容收藏Fragment
 * 
 * @author dsawe
 * 
 */
public class CollectionItemFragment extends BaseFragment implements Observer {
	ViewPager pager;
	PagerSlidingTabStrip tabs;
	ListView listview;
	GoodsCollectionAdapter adapter;
	ArrayList<GoodsListModel.GoodsList> list;
	TieZiPresenter presenter;
	@Override
	public int initView() {
		// TODO Auto-generated method stub
		return R.layout.fragment_goodscollection;
	}


	@Override
	public void onMyActivityCreated() {
		list=new ArrayList<GoodsListModel.GoodsList>();
		presenter=new TieZiPresenter(this);
		presenter.queryCollection((String)SPUtils.get(getActivity(), null, SpPublicParams.UID, ""), 5+"", 1+"","");
//		for (int i = 0; i < 30; i++) {
//			GoodsListModel.GoodsList goodsList=new GoodsListModel.GoodsList();
//			list.add(goodsList);
//		}
		adapter=new GoodsCollectionAdapter(getActivity(), list);
		listview.setAdapter(adapter);
	}


	@Override
	public void update(Observable observable, Object data) {
		ResultEntity model = super.handlerError(data);
		if (model != null) {
			ByAlert.alert(model.getData()+"");
//			model.getData();
//			if(model)
//			tabs.setFillViewport(false);
//			IndexModel arrayBanner = (IndexModel) model.getData();
//			titles = new String[arrayBanner.getCate().size()];
//			for (int i = 0; i < arrayBanner.getCate().size(); i++) {
//				titles[i] = arrayBanner.getCate().get(i).getName();
//			}
//			pager.setAdapter(new MyAdapter(getSupportFragmentManager(), titles));
//			tabs.setViewPager(pager);
		}
	}
}
